//
//  LNHomeThemeItem.m
//  LNDevelopExample
//
//  Created by wwww on 2018/9/28.
//  Copyright © 2018年 淘发现1iOS. All rights reserved.
//

#import "LNHomeThemeItem.h"

@interface LNHomeThemeItem()

@end

@implementation LNHomeThemeItem

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self setupUI];
    }
    return self;
}

+(LNHomeThemeItem *)themeItemWithTitle:(NSString *)title  icon:(NSString *)icon{
    
    LNHomeThemeItem *item = [[LNHomeThemeItem alloc] init];
    item.titleLabel.text = title;
    item.iconImg.image = LNImageNamed(icon);
    
    return item;
}

#pragma mark - 初始化UI
-(void)setupUI{
    
    [self addSubview:self.iconImg];
    [self addSubview:self.titleLabel];
    
    
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).offset(10);
        make.width.height.mas_equalTo(40);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.iconImg.mas_bottom);
        make.left.right.mas_equalTo(self);
    }];
}

#pragma mark - setter and getter
-(UIImageView *)iconImg{
    if (_iconImg == nil) {
        _iconImg = [[UIImageView alloc] init];
    }
    return _iconImg;
}

-(UILabel *)titleLabel{
    if(_titleLabel == nil){
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = LNRegularFont_12;
        _titleLabel.textColor = [UIColor blackColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}
@end
